package com.oo.polymorphic_4.fruit;

import java.util.Scanner;

/**
 * FruitTest--${description}
 *
 * @author: Jovi
 * @createTime: 2017-05-09 15:15
 **/
public class FruitTest {

    public static void main(String[] args) {
        Durian d = new Durian("榴莲", "闻着臭，吃着香");

        Cantaloup c = new Cantaloup("哈密瓜", "甜甜的");

        Jujube j = new Jujube("酸枣", "酸的");

        System.out.println("请选择需要购买的水果：（1、榴莲，2、哈密瓜，3、酸枣）");
        Scanner sc = new Scanner(System.in);
        int id = sc.nextInt();
        Fruit f = null;
        switch (id) {
            case 1:
                f = d;
                break;
            case 2:
                f = c;
                break;
            case 3:
                f = j;
                break;
        }
        if (f != null) {
            f.eat();
        }
    }
}
